package com.business.dashboard.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.business.dashboard.entity.User;
import com.business.dashboard.entity.UserFollow;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户关注关系数据访问层
 * 
 * @author Claude
 * @since 2025-07-06
 */
@Mapper
public interface UserFollowDao extends BaseMapper<UserFollow> {

    /**
     * 根据关注者和被关注者查询关注关系
     */
    @Select("SELECT * FROM user_follows WHERE follower_id = #{followerId} AND followed_id = #{followedId}")
    UserFollow selectByFollowerAndFollowed(@Param("followerId") Long followerId, 
                                          @Param("followedId") Long followedId);

    /**
     * 取消关注
     */
    @Delete("DELETE FROM user_follows WHERE follower_id = #{followerId} AND followed_id = #{followedId}")
    int deleteByFollowerAndFollowed(@Param("followerId") Long followerId, 
                                   @Param("followedId") Long followedId);

    /**
     * 获取关注列表
     */
    List<User> selectFollowingList(@Param("userId") Long userId, 
                                  @Param("page") int page, 
                                  @Param("size") int size);

    /**
     * 获取粉丝列表
     */
    List<User> selectFollowersList(@Param("userId") Long userId, 
                                  @Param("page") int page, 
                                  @Param("size") int size);

}